/*Joseph A. Coll
Cleaning 2020 SPAE
8/2/2021 */

*Load
use "G:\My Drive\Backup 08202022\Working Papers\Michaels Edited Volume\Election Policies Fraud Beliefs Confidence\Data and Methods\2020 SPAE.dta" , clear

gen year = 2020

*Voted
tab q1
recode q1 (1/5=0 "Did not vote") (6=1 "Voted"), gen(voted)
label var voted Voted
tab voted 

*Reason for not voting, second reason
tab q2
tab q2_t
tab q2a

*First time voters
tab q3
recode q3 (1 9=1 "First Time Voter") (2=0 "Not First Time Voter") (9/99=1), gen(voted_first_time)
label var voted_first_time "First Time Voter"

tab q3_t

*Mode of voting 
tab q4 
recode q4 (1=1 "Voted on Election Day") (2=2 "Voted Prior to Election-Day") ///
(3=3 "Voted Absentee/Mail") (9/99=.), gen(voted_how)
label var voted_how "How Respondent Voted"
tab voted_how
tab voted_how if voted_how <3

recode q4 (1/2=1 "Voted in Person") (3=0 "Voted by Mail/Absentee") (9/99=1), gen(voted_inperson)
label var voted_inperson "Voted In-Person"

recode q4 (1=0 "Voted on Election Day") (2=1 "Voted Prior to Election-Day") ///
(3 9/99=0), gen(voted_earlymail)
label var voted_early "Voted Early/Mail"

recode q4 (1 3=0 "Voted on Election Day/Mail") (2=1 "Voted Early") ///
( 9/99=0), gen(voted_early)
label var voted_early "Voted Early"

recode q4 (1/2=0 "Did not Vote by Mail") (3=1 "Voted by Mail") ///
(4/99=0), gen(voted_mail)
label var voted_mail "Voted by Mail"

recode q4 (1=1 "Election Day") (2 3=0 "After Election Day") (4/99=0), gen(voted_ed)
label var voted_ed "Voted on Election Day"


*Difficutly Finding Polling Place
tab q5
recode q5 (1=4 "Very Difficult") (2=3 "Somewhat Difficult") (3=2 "Fairly Easy") ///
(4=1 "Very Easy") (9/99=1) (.=1), gen(difficulty_finding_poll)
label var difficulty_finding_poll "Difficulty Finding Polling Place"

*Polling place type
tab q6
recode q6 (1=1 "Private Business") (2=2 "School") (3=3 "Church") (4=4 "Police/Fire Station") ///
(5=5 "Store/Mall") (6=6 "Senior Center") (7=7 "Community Center") (8=8 "Library") ///
(9=9 "Sports Arena") (10=10 "Gov't Office") (11=11 "Other") (9/999=.), gen(poll_type)
label var poll_type "Type of Polling Place"

*Knew who checked you in
tab q7
recode q7 (1=1 "Yes") (2/9=0 "No") (9/99=.), gen(knew_checkin_worker)
label var knew_checkin "Knew the Check-in Worker"

*Polling place run evaluation
tab q8
tab q8 q4
sum q8 if q8 < 5
recode q8 (1=4 "Very Well") (2=3 "Okay") (3=2 "Not Well") (4=1 "Terrible") ///
(9/99=.), gen(poll_eval4)
label var poll_eval4 "Poll Place Eval."

tab q8
recode q8 (1=3 "Very Well") (2=2 "Okay") (3/4=1 "Not Well") ///
(9/99=.), gen(poll_eval3)
label var poll_eval3 "Poll Place Eval."

recode q8 (1=1 "Very Well") (2/4=0 "Not Very Well") ///
(9/99=.), gen(poll_eval2)
label var poll_eval2 "Poll Place Eval."

*Voter registration problem
tab q9
recode q9 (1=1 "Yes") (2/9=0 "No") (9=0) (99=1) (.=0), gen(reg_problem)
label var reg_problem "Reg. Problems"

*Time voted
tab q10
recode q10 (1=1 "Before 5 AM") (2=2 "5-6 AM") (3=3 "6-7 AM") (4=4 "7-8 AM") ///
(5=5 "8-9 AM") (6=6 "9-10 AM") (7=7 "10-11 AM") (8=8 "11-12 PM") (9=9 "12-1 PM") ///
(10=10 "1-2 PM") (11=11 "2-3 PM") (12=12 "3-4 PM") (13=13 "4-5 PM") (14=14 "5-6 PM") ///
(15=15 "6-7 PM") (16=16 "7-8 PM") (17=17 "8-9 PM") (18=18 "After 9 PM") (9/999=.) ///
, gen(voted_time18)
labe var voted_time18 "Time Voted"

recode q10 (1/4=1 "Before 8 AM") (5=2 "8-9 AM") (6=3 "9-10 AM") (7=4 "10-11 AM") ///
(8=5 "11-12 PM") (9=6 "12-1 PM") (10=7 "1-2 PM") (11=8 "2-3 PM") (12=9 "3-4 PM") ///
(13=10 "4-5 PM") (14/18=11 "After 5 PM") (9/999=.) ///
, gen(voted_time11)
labe var voted_time11 "Time Voted"

gen voted_time9_12 = 1 if voted_time11 >2 | voted_time11  <6 
replace voted_time9_12 = 0 if voted_time11 <3 | voted_time11 >5
label var voted_time9_12 "Morning Voter"

*Polling place closed
tab q11
recode q11 (1=0 "Open") (2=1 "Closed") (9/99=.), gen(poll_closed)
label var poll_closed "Polling Place was Closed"

*How voting fit into schedule
tab q12

*Errands and voting
tab q13

*Wait time
tab q14
tab q14 if q14 < 99
recode q14 (1=1 "No wait") (2=2 "<10 Min.") (3=3 "10-30 Min.") (4=4 "30-60 Min.") ///
(5=5 ">60 Min.") (9/99=.), gen(wait_time5)
label var wait_time5 "Wait Time"

recode q14 (1=1 "No wait") (2=2 "<10 Min.") (3=3 "10-30 Min.") (4/5 =4 ">30 Min.") ///
(9/99=1), gen(wait_time4)
label var wait_time4 "Wait Time"

recode q14 (1=1 "No wait") (2=2 "<10 Min.") (3/5=3 ">10 Min.") (9/99=1), gen(wait_time3)
label var wait_time3 "Wait Time"

recode q14 (1=0 "No wait") (2/5=1 "Waited") (9/99=1), gen(wait_time2)
label var wait_time2 "Waited to Vote"
tab wait_time5 wait_time2 

*Where wait occurred
tab q15
tab q15 if q22_1 < 9 & q15 <9
recode q15 (1=1 "Check In") (2=3 "Voting Queue") (3=2 "Evenly Split") (9/99=.) ///
, gen(wait_where_happened3)
recode q15 (1=0 "Check In") (2/3=1 "Voting Queue") (9/99=.) ///
, gen(wait_where_happened2)
sum wait_where_happened3 wait_where_happened2

*Showed ID
tab q16
tab q16 if q16 != 99
recode q16 (1=0 "Gave Name/Address") (2/7=1 "Proved ID") (8 9/99=.), gen(proved_id)
label var proved_id "Proved Identification"

recode q16 (1/2=0 "Showed No ID") (3/7=1 "Showed ID") (8 9/99=.), gen(showed_id)
label var showed_id "Showed Identification"

*Asked for ID
tab q17
gen asked_photo  = 1 if q17 ==1 
replace asked_photo  = 0 if asked_photo   != 1 & q4 <8
labe var asked_photo  "Asked for Photo ID"
tab asked_photo 

*Voting machine problem
tab q18
tab q18, nol
recode q18 (1=1 "Yes") (2/9=0 "No") (9=0) (99=0) (.=0), gen(machine_problem)
label var machine_problem "Voting Problems"

*Poll worker eval
tab q19
tab q19 q4
recode q19 (1=4 "Excellent") (2=3 "Good") (3=2 "Fair") (4=1 "Poor") (9/99=.), gen(pollworker_eval4)
label var pollworker_eval4 "Poll Worker Eval."
tab pollworker_eval4

recode q19 (1=3 "Excellent") (2=2 "Good") (3/4=1 "Fair") (9/99=.), gen(pollworker_eval3)
label var pollworker_eval3 "Poll Worker Eval."
tab pollworker_eval3 

recode q19 (1=1 "Excellent") (2/4=0 "Less than Excellent") (9/99=.), gen(pollworker_eval2)
label var pollworker_eval2 "Poll Worker Eval."
tab pollworker_eval2

*Poll worker race
tab q20
recode q20 (1/3 5/6 9=1 "Non-White Poll Worker") (4=0 "White Poll Worker") ///
(8/99=.), gen(pollworker_race)
label var pollworker_race "Poll Worker Race"
tab pollworker_race

*Poll worker age
tab q21 
recode q21 (1=1 "<30") (2=2 "31-50") (3=3 "51-70") (4=4 "70+") (9/99=.), gen(pollworker_age)
label var pollworker_age "Poll Worker Age"

*Social Distance precautions
tab q22_1
local vars q22_1 q22_2 q22_3 q22_4 q22_5 q22_6 q22_7 q22_8 q22_9
foreach x of local vars { 
recode `x' (1=1 "Yes") (2=0 "No") (9/99=.), gen(`x'_recode)
}

*PW masks
rename q22_1_recode sd_pw_masks
label var sd_pw_masks "Poll Workers w. Masks"
label def sd_pw_masks 0 "Poll Workers w/o. Masks" 1 "Poll Workers w. Masks"
label val sd_pw_masks sd_pw_masks 

*PW Faceshield
rename q22_2_recode sd_pw_faceshield
label var sd_pw_faceshield "Poll Workers w. Face Shields"
label def sd_pw_faceshield 0 "Poll Workers w/o. Face Shields" 1 "Poll Workers w. Face Shields"
label val sd_pw_faceshield sd_pw_faceshield 

	*PW Mask or shield
	gen sd_pw_covering =1 if sd_pw_masks == 1 | sd_pw_faceshield == 1 
	replace sd_pw_covering = 0 if sd_pw_masks == 0 & sd_pw_faceshield == 0 
	label var sd_pw_covering "Face Coverings"
	label def sd_pw_covering 0 "Poll Workers w/o. Face Coverings" 1 "Poll Workers w. Face Coverings"
	label val sd_pw_covering sd_pw_covering 
	
*Worker voter barrier
rename q22_3_recode sd_barrier_pwvoter
label var sd_barrier_pwvoter "Barriers b/w Workers and Voters"
label def sd_barrier_pwvoter 0 "No Barriers b/w Workers and Voters" 1 "Barriers b/w Workers and Voters"
label val sd_barrier_pwvoter sd_barrier_pwvoter 

*Voter voter barrier
rename q22_4_recode sd_barrier_booths
label var sd_barrier_booths "Barriers b/w Voting Booths"
label def sd_barrier_booths 0 "No Barriers b/w Voting Booths" 1 "Barriers b/w Voting Booths"
label val sd_barrier_booths sd_barrier_booths 

	*Both Barriers 
	gen sd_barriers =1 if sd_barrier_pwvoter == 1 | sd_barrier_booths == 1 
	replace sd_barriers = 0 if sd_barrier_pwvoter == 0 & sd_barrier_booths == 0 
	label var sd_barriers "Protective Barriers"
	label def sd_barriers 0 "No Protective Barriers" 1 "Protective Barriers"
	label val sd_barriers sd_barriers 
	
*booths 6 feet
rename q22_5_recode sd_booth_placement
label var sd_booth_placement "Voting Booths Separated"
label def sd_booth_placement 0 "Voting Booths not Separated" 1 "Voting Booths Separated"
label val sd_booth_placement sd_booth_placement 

*Voters 6 feet
rename q22_6_recode sd_sixfeet
label var sd_sixfeet "Social Distanced Voter Lines"
label def sd_sixfeet 0 "Non-Social Distanced Voter Lines" 1 "Social Distanced Voter Lines"
label val sd_sixfeet sd_sixfeet 

	*Social distanced votin
	gen sd_space =1 if sd_booth_placement == 1 | sd_sixfeet == 1 
	replace sd_space = 0 if sd_booth_placement == 0 & sd_sixfeet == 0 
	label var sd_space "Socially Distanced"
	label def sd_space 0 "Non-Socially Distanced" 1 "Socially Distanced"
	label val sd_space sd_space 

*Hand sanitizer
rename q22_7_recode sd_handsanitizer
label var sd_handsanitizer "Sanitizer Available"
label def sd_handsanitizer 0 "Sanitizer not Available" 1 "Sanitizer Available"
label val sd_handsanitizer sd_handsanitizer 

*Single use pens
rename q22_8_recode sd_singleusepens
label var sd_singleusepens "Single Use Pens"
label def sd_singleusepens 0 "No Single Use Pens" 1 "Single Use Pens"
label val sd_singleusepens sd_singleusepens 

rename q22_9_recode sd_boothscleaned
label var sd_boothscleaned "Booths Cleaned"
label def sd_boothscleaned 0 "Booths not Cleaned" 1 "Booths Cleaned"
label val sd_boothscleaned sd_boothscleaned 

sum sd_*

gen sd_index9 = 0
replace sd_index9 = sd_index9 + 1 if   sd_pw_masks  == 1       
replace sd_index9 = sd_index9 + 1 if   sd_pw_faceshield  == 1       
replace sd_index9 = sd_index9 + 1 if   sd_barrier_pwvoter == 1       
replace sd_index9 = sd_index9 + 1 if   sd_barrier_booths  == 1       
replace sd_index9 = sd_index9 + 1 if   sd_booth_placement  == 1       
replace sd_index9 = sd_index9 + 1 if   sd_sixfeet  == 1       
replace sd_index9 = sd_index9 + 1 if   sd_handsanitizer  == 1       
replace sd_index9 = sd_index9 + 1 if   sd_singleusepens  == 1       
replace sd_index9 = sd_index9 + 1 if   sd_boothscleaned  == 1       
sum sd_index9 if q4 <3
tab sd_index9 if q4 <3
label var sd_index9 "Covid Safety Index"

gen sd_index_wait = 0
replace sd_index_wait = sd_index_wait + 1 if   sd_pw_masks  == 1       
replace sd_index_wait = sd_index_wait + 1 if   sd_pw_faceshield  == 1       
replace sd_index_wait = sd_index_wait + 1 if   sd_barrier_pwvoter == 1       
replace sd_index_wait = sd_index_wait + 1 if   sd_barrier_booths  == 1       
replace sd_index_wait = sd_index_wait + 1 if   sd_booth_placement  == 1       
replace sd_index_wait = sd_index_wait + 1 if   sd_sixfeet  == 1       
replace sd_index_wait = sd_index_wait + 1 if   sd_boothscleaned  == 1       
sum sd_index_wait if q4 <3
tab sd_index_wait if q4 <3
label var sd_index_wait "Covid Safety Index"

*Pens reversed
clonevar sd_index9_penrev = sd_index9
replace sd_index9_penrev = sd_index9_penrev  -1 if sd_singleusepens == 1 

*6 point
gen sd_index6 = 0
replace sd_index6 = sd_index6 + 1 if   sd_pw_covering  == 1       
replace sd_index6 = sd_index6 + 1 if   sd_barriers == 1       
replace sd_index6 = sd_index6 + 1 if   sd_space  == 1       
replace sd_index6 = sd_index6 + 1 if   sd_handsanitizer  == 1       
replace sd_index6 = sd_index6 + 1 if   sd_singleusepens  == 1       
replace sd_index6 = sd_index6 + 1 if   sd_boothscleaned  == 1       
sum sd_index6 if q4 <3
tab sd_index6 if q4 <3
label var sd_index6 "Covid Safety Index"


*Pens reversed
clonevar sd_index6_penrev = sd_index6
replace sd_index6_penrev = sd_index6_penrev  -1 if sd_singleusepens == 1 

*Check in-relevant

*Voting-Relevant



*Confidence in social distancing
tab q23
recode q23 (1=4 "Very Confident") (2=3 "Somewhat Confident") (3=2 "Not Too Confident") ///
(4=1 "Not at All Confident") (9/99=.), gen(sd_confidence4)
label var sd_confidence4 "Confidence in Social Distancing Measures"

recode q23 (1=3 "Very Confident") (2=2 "Somewhat Confident") (3/4=1 "Not Too Confident") ///
(9/99=.), gen(sd_confidence3)
label var sd_confidence3 "Confidence in Social Distancing Measures"
tab sd_confidence3 

recode q23 (1=1 "Very Confident") (2=0 "Somewhat Confident") (3/4=0 "Not Too Confident") ///
(9/99=.), gen(sd_confidence2)
label var sd_confidence2 "Confidence in Social Distancing Measures"
tab sd_confidence2 

*Why absentee
tab q24

*Issues with getting mail ballot
tab q25
tab q25 if q4 == 3 
	*Only 2 percent

*Problem marking mail ballot
tab q26
tab q26 if q4 == 3 
	*Only 1 percent

*How returned mail ballot
tab q27
tab q27 if q4 == 3 
recode q27 (1=1 "Returned Mail Ballot in Person") (2=0 "Returned Mail Ballot by Mail") ///
(9/99=.), gen(returned_ballot_inperson)
tab returned_ballot_inperson

*Who returned mail ballot
tab q28
tab q28 if q4 == 3 
tab q28 if returned_ballot_inperson == 1 

*Where returned ballot
tab q29
label def drop_off_location ///
1 "Post office box at a U.S. Postal Service location" ///
2 "Official post office box not at a U.S. Postal Service location" ///
3 "Picked up by the postal worker who delivers mail to my home" ///
4 "Drop box used only for ballots, not located at an election office or polling place" ///
5 "Main election office" ///
6 "Neighborhood polling place" ///
7 "Voting center, not a neighborhood polling place" ///
8 "Other"
clonevar drop_off_location = q29
replace  drop_off_location = . if  drop_off_location == 99
replace  drop_off_location = 8 if  drop_off_location == 9
 label val drop_off_location drop_off_location
*How returning ballot fit into day
tab q30

*Errands and ballot
tab q31

*Time to return mail ballot
tab q32 if q32 != 99
replace wait_time5 = 1 if q32 == 1
replace wait_time5 = 2 if q32 == 2
replace wait_time5 = 3 if q32 == 3
replace wait_time5 = 4 if q32 == 4
replace wait_time5 = 5 if q32 == 5
replace wait_time5 = 1 if q32 ==9

*Conveneince of drop off location
tab q33

*Difficulty finding drop off
tab q34
recode q34 (1/3=0 "Not Very Easy") (4=1 "Very East") (9/99=.), ///
gen(difficulty_finding_poll_dropoff)
tab q34 if returned_ballot_inperson == 1 

*Drop off site type 
tab q35
tab q35 if returned_ballot_inperson == 1 

*Perfomance of Drop Off Staff
tab q36
tab q36 if returned_ballot_inperson == 1 
tab q36 if returned_ballot_inperson == 1 & q36 <5
tab q36 if q37_1 <9
tab q36 if q37_2 <9
tab q36 if q37_3 <9
tab q36 if q37_4 <9
tab q36 if q37_5 <9
tab q36 if q37_6 <9
tab q36 if q37_7 <9
tab q36 if q37_8 <9
tab q36 if q37_9 <9

tab q32 if returned_ballot_inperson == 1  

*Social Distance precautions Drop Offs
tab q37_1 
tab q37_2 
local vars1 q37_1 q37_2 q37_3 q37_4 q37_5 q37_6 q37_7 q37_8 q37_9
local vars2 q4
foreach x of local vars1 {
	foreach y of local vars2 {
	tab `y' `x'
	}
	}
local vars q37_1 q37_2 q37_3 q37_4 q37_5 q37_6 q37_7 q37_8 q37_9
foreach x of local vars { 
recode `x' (1=1 "Yes") (2=0 "No") (9/99=.), gen(`x'_recode)
}

rename q37_1_recode sd_pw_masks_dropoff
label var sd_pw_masks_dropoff "Social Distancing (Drop-Off): Poll Workers Wore Masks"
rename q37_2_recode sd_pw_faceshield_dropoff
label var sd_pw_faceshield_dropoff "Social Distancing (Drop-Off): Poll Workers Wore Face Shields"
rename q37_3_recode sd_barrier_pwvoter_dropoff
label var sd_barrier_pwvoter_dropoff "Social Distancing (Drop-Off): Barrier Between Poll Workers and Voters"
rename q37_4_recode sd_barrier_booths_dropoff
label var sd_barrier_booths_dropoff "Social Distancing (Drop-Off): Barrier Between Voting Booths"
rename q37_5_recode sd_booth_placement_dropoff
label var sd_booth_placement_dropoff "Social Distancing (Drop-Off): Voting Booths Spaced Out"
rename q37_6_recode sd_sixfeet_dropoff
label var sd_sixfeet_dropoff "Social Distancing (Drop-Off): Six Foot Spacing in Voter Lines"
rename q37_7_recode sd_handsanitizer_dropoff
label var sd_handsanitizer_dropoff "Social Distancing (Drop-Off): Hand Sanitizer Available"
rename q37_8_recode sd_singleusepens_dropoff
label var sd_singleusepens_dropoff "Social Distancing (Drop-Off): Single Use Ballot Pens Used"
rename q37_9_recode sd_boothscleaned_dropoff
label var sd_boothscleaned_dropoff "Social Distancing (Drop-Off): Voting Booths Cleaned After Use"

gen sd_pw_masks_both = 1 if sd_pw_masks ==1 | sd_pw_masks_dropoff == 1
replace sd_pw_masks_both = 0 if sd_pw_masks_both !=1 

gen sd_pw_faceshield_both = 1 if sd_pw_faceshield ==1 | sd_pw_faceshield_dropoff == 1
replace sd_pw_faceshield_both = 0 if sd_pw_faceshield_both !=1 

gen sd_barrier_pwvoter_both = 1 if sd_barrier_pwvoter ==1 | sd_barrier_pwvoter_dropoff == 1
replace sd_barrier_pwvoter_both = 0 if sd_barrier_pwvoter_both !=1 

gen sd_barrier_booths_both = 1 if sd_barrier_booths ==1 | sd_barrier_booths_dropoff == 1
replace sd_barrier_booths_both = 0 if sd_barrier_booths_both !=1 

gen sd_booth_placement_both = 1 if sd_booth_placement ==1 | sd_booth_placement_dropoff == 1
replace sd_booth_placement_both = 0 if sd_booth_placement_both !=1 

gen sd_sixfeet_both = 1 if sd_sixfeet ==1 | sd_sixfeet_dropoff == 1
replace sd_sixfeet_both = 0 if sd_sixfeet_both !=1 

gen sd_handsanitizer_both = 1 if sd_handsanitizer ==1 | sd_handsanitizer_dropoff == 1
replace sd_handsanitizer_both = 0 if sd_handsanitizer_both !=1 

gen sd_singleusepens_both = 1 if sd_singleusepens ==1 | sd_singleusepens_dropoff == 1
replace sd_singleusepens_both = 0 if sd_singleusepens_both !=1 

gen sd_boothscleaned_both = 1 if sd_boothscleaned ==1 | sd_boothscleaned_dropoff == 1
replace sd_boothscleaned_both = 0 if sd_boothscleaned_both !=1 

local vars sd_pw_masks_both sd_pw_faceshield_both sd_barrier_pwvoter_both sd_barrier_booths_both sd_booth_placement_both sd_sixfeet_both sd_handsanitizer_both sd_singleusepens_both sd_boothscleaned_both
foreach x of local vars {
	tab `x'
	}


gen sd_index_dropoff = 0
replace sd_index_dropoff = sd_index_dropoff + 1 if   sd_pw_masks_dropoff  == 1       
replace sd_index_dropoff = sd_index_dropoff + 1 if   sd_pw_faceshield_dropoff  == 1       
replace sd_index_dropoff = sd_index_dropoff + 1 if   sd_barrier_pwvoter_dropoff == 1       
replace sd_index_dropoff = sd_index_dropoff + 1 if   sd_barrier_booths_dropoff  == 1       
replace sd_index_dropoff = sd_index_dropoff + 1 if   sd_booth_placement_dropoff  == 1       
replace sd_index_dropoff = sd_index_dropoff + 1 if   sd_sixfeet_dropoff  == 1       
replace sd_index_dropoff = sd_index_dropoff + 1 if   sd_handsanitizer_dropoff == 1       
replace sd_index_dropoff = sd_index_dropoff + 1 if   sd_singleusepens_dropoff  == 1       
replace sd_index_dropoff = sd_index_dropoff + 1 if   sd_boothscleaned_dropoff  == 1       
sum sd_index_dropoff if q4 == 3
tab sd_index_dropoff if q4 == 3
local vars sd_pw_masks_dropoff sd_pw_faceshield_dropoff sd_barrier_pwvoter_dropoff sd_barrier_booths_dropoff sd_booth_placement_dropoff sd_sixfeet_dropoff sd_handsanitizer_dropoff sd_singleusepens_dropoff sd_boothscleaned_dropoff
foreach x of local vars {
tab `x' 
}

local vars sd_pw_masks sd_pw_faceshield sd_barrier_pwvoter sd_barrier_booths sd_booth_placement sd_sixfeet sd_handsanitizer sd_singleusepens sd_boothscleaned
foreach x of local vars {
tab `x' 
}

*Confidence in social distancing
tab q38
tab q38 if returned_ballot_inperson == 1 
recode q38 (1=4 "Very Confident") (2=3 "Somewhat Confident") (3=2 "Not Too Confident") ///
(4=1 "Not at All Confident") (8/99=.), gen(sd_confidencemail)
label var sd_confidencemail "Confidence in Social Distancing Measures (Drop Off)"
replace sd_confidence3 = 1 if sd_confidencemail <3
replace sd_confidence3 = 2 if sd_confidencemail ==3
replace sd_confidence3 = 3 if sd_confidencemail ==4

recode q38 (1=3 "Very Confident") (2=2 "Somewhat Confident") (3=1 "Not Too Confident") ///
(4=1 "Not at All Confident") (9/99=.), gen(sd_confidencemail3)

gen sd_confidence3_both = sd_confidencemail3 if q4 >2
replace sd_confidence3_both = sd_confidence3 if q4 <3

*When returned absentee ballot
tab q39

*Ease filling out absentee ballot
tab q40

*Typically vote by mail
tab q41

*Likelihood of votig by mail in future
tab q42

*Confidence in mail ballot security measures
tab q43
recode q43 (1=4 "Very Confident") (2=3 "Somewhat Confident") (3=2 "Not too Confident") ///
(4=1 "Not at All Confident") (9/99=0), gen(confidence_security)
label var confidence_security "Confidence in Mail Ballot Security Measures"

*confidence in own vote count
tab q44
recode q44 (1=4 "Very Confident") (2=3 "Somewhat Confident") (3=2 "Not too Confident") ///
(4=1 "Not at All Confident") (9/99=.), gen(confidence_ownvote)
label var confidence_ownvote "Confidence Own Vote Counted Correctly"

*confidence in county vote count
tab q45
recode q45 (1=4 "Very Confident") (2=3 "Somewhat Confident") (3=2 "Not too Confident") ///
(4=1 "Not at All Confident") (9/99=.), gen(confidence_countyvote)
label var confidence_countyvote "Confidence Local Votes Counted Correctly"

*confidence in state vote count
tab q46
recode q46 (1=4 "Very Confident") (2=3 "Somewhat Confident") (3=2 "Not too Confident") ///
(4=1 "Not at All Confident") (9/99=.), gen(confidence_statevote)
label var confidence_statevote "Confidence State Votes Counted Correctly"
clonevar confidence_statevote_original = q46 

*confidence in natl vote count
tab q47
recode q47 (1=4 "Very Confident") (2=3 "Somewhat Confident") (3=2 "Not too Confident") ///
(4=1 "Not at All Confident") (9/99=.), gen(confidence_natlvote)
label var confidence_natlvote "Confidence National Votes Counted Correctly"

*Generate Binary Variables
	gen  confidence_ownvote_binary =1 if  confidence_ownvote >3
	replace confidence_ownvote_binary = 0 if confidence_ownvote < 4
	
	gen  confidence_countyvote_binary =1 if  confidence_countyvote >3
	replace confidence_countyvote_binary = 0 if confidence_countyvote < 4
	
	gen  confidence_statevote_binary =1 if  confidence_statevote >3
	replace confidence_statevote_binary = 0 if confidence_statevote < 4
	
	gen  confidence_natlvote_binary =1 if  confidence_natlvote >3
	replace confidence_natlvote_binary = 0 if confidence_natlvote < 4
	

*Beleive outcome is fair
tab q47b
tab q47b, nol

recode q47b (1=7 "Strongly Agree") (2=6 "Agree") (3=5 "Somewhat Agree") (4=4 "Neither Agree or Disagree") ///
(5=3 "Somewhat Disagree") (6=2 "Disagree") (7=1 "Strongly Disagree") (98/99=4), gen(outcome_fair)
tab outcome_fair

*COVID 19 and best interests
tab q48a 
local vars q48a q48b q48c q48d q48e q48f
foreach x of local vars {
recode `x' (1=4 "A Great Deal") (2=3 "A Fair Amount") (3=2 "Not too Much") ///
(4=1 "Not at All") (8/99=.), gen(`x'_recode)
}
   
label var q48a_recode   "Confidence State Election Officials Acted in Best Interest vis-a-vis COVID-19 Policy"
label var q48b_recode   "Confidence Local Election Officials Acted in Best Interest vis-a-vis COVID-19 Policy"
label var q48c_recode   "Confidence State Governor Acted in Best Interest vis-a-vis COVID-19 Policy"
label var q48d_recode   "Confidence State Legislature Acted in Best Interest vis-a-vis COVID-19 Policy"
label var q48e_recode   "Confidence U.S. Congress Acted in Best Interest vis-a-vis COVID-19 Policy"
label var q48f_recode   "Confidence President Trump Acted in Best Interest vis-a-vis COVID-19 Policy"

rename q48a_recode covid_policy_state
rename q48b_recode covid_policy_local
rename q48c_recode covid_policy_governor
rename q48d_recode covid_policy_stateleg
rename q48e_recode covid_policy_fedleg
rename q48f_recode covid_policy_pres

*Committed to fair and accurate counts
tab q45a 
tab q45b 
tab q45c 
tab q45d 
tab q45e 
tab q45f 
tab q45g 
tab q45h

*PO in public policy
tab q50
recode q50 (1=1 "Opinion Should Influence Policy") (2=2 "Opinion Should not Influence Policy") ///
(8=.) (9/99=.), gen(po_and_policy)
label var po_and_ "Public Opinion Should Influence Public Policy"

*Voting experience
tab q47a 
tab q47a q4
recode q47a (1=7 "Strongly Agree") (2=6 "Agree") (3=5 "Somewhat Agree") ///
(4=4 "Neither") (5=3 "Somewhat Disagree") (6=2 "Disagree") (7=1 "Strongly Disagree") ///
(9/99=.), gen(votingexp7)
label var votingexp7 "Voting Experience"

recode q47a (1=5 "Strongly Agree") (2=4 "Agree") (3=3 "Somewhat Agree") ///
(4=2 "Neither") (5/7=1 "Somewhat/Strongly Disagree") ///
(9/99=.), gen(votingexp5)
label var votingexp5 "Voting Experience"

recode q47a (1=4 "Mostly Positive") (2=3 "Positive") (3=2 "Somewhat Positive") ///
(4/7=1 "Neither/Not Positive")  ///
(9/99=.), gen(votingexp4)
label var votingexp4 "Voting Experience"

recode q47a (1=1 "Mostly Positive") (2/7=0 "Not Mostly Positive") ///
(9/99=.), gen(votingexp2)
label var votingexp2 "Voting Experience"

*Voting outcomes to be fair
tab q47b

*Influences and corruption
tab q52a 
tab q52b 
tab q52c 
tab q52d

*Family/Self catching covid
tab q53
recode q53 (1=4 "Very Worried") (2=3 "Somewhat Worried") (3=2 "Not too Worried") ///
(4=1 "Not at all Worried") (8=.) (9/99=.), gen(covid_worry)
label var covid_worry "Covid Worry"

*Voter fraud
tab q54a 
tab q54b 
tab q54c 
tab q54d 
tab q54e 
tab q54f

*Fraud
	*Vote multiple times
	tab q54a 
	tab q54a, nol
	recode q54a (1=5 "Very Common") (2=4 "Occasional") (3=2 "Infrequent") (4=1 "Never") ///
	(5/99 . =3 "Unsure" ), gen(fraud_voter)
	label var fraud_voter "Repeat Voting"
	tab fraud_voter
	
	recode q54a (1/3 5 9 98 . =1 "Frequently") (4=0 "Almost Never"), gen(fraud_voter_binary)
	label var fraud_voter_binary "Repeat Voting"
	tab fraud_voter_binary
	
	*Steal ballots
	tab q54b 
	tab q54b, nol
	recode q54b (1=5 "Very Common") (2=4 "Occasional") (3=2 "Infrequent") (4=1 "Never") ///
	(5/99 . =3 "Unsure" ), gen(fraud_tamper)
	label var fraud_tamper "Tampering with Casr Ballots"
	tab fraud_tamper

	recode q54b (1/3 5 9 98 . =1 "Frequently") (4=0 "Almost Never"), gen(fraud_tamper_binary)
	label var fraud_tamper_binary "Vote Theft"
	tab fraud_tamper_binary

	*Impersonation
	tab q54c
	tab q54c, nol
	recode q54c (1=5 "Very Common") (2=4 "Occasional") (3=2 "Infrequent") (4=1 "Never") ///
	(5/99 . =3 "Unsure" ),gen(fraud_impersonation)
	label var fraud_impersonation "Voter Impersonation"
	tab fraud_impersonation

	recode q54c (1/3 5 9 98 . =1 "Frequently") (4=0 "Almost Never"), gen(fraud_impersonation_binary)
	label var fraud_impersonation_binary "Voter Impersonation"
	tab fraud_impersonation_binary

	*Non-Citizen voters
	tab q54d
	tab q54d, nol
	recode q54d (1=5 "Very Common") (2=4 "Occasional") (3=2 "Infrequent") (4=1 "Never") ///
	(5/99 . =3 "Unsure" ), gen(fraud_noncitizen)
	label var fraud_noncitizen "Non-Citizen Voting"
	tab fraud_noncitizen

	recode q54d (1/3 5 9 98 . =1 "Frequently") (4=0 "Almost Never"), gen(fraud_noncitizen_binary)
	label var fraud_noncitizen_binary "Non-Citizen Voting"
	tab fraud_noncitizen_binary

	*Illegal absentee 
	tab q54e
	tab q54e, nol
	recode q54e (1=5 "Very Common") (2=4 "Occasional") (3=2 "Infrequent") (4=1 "Never") ///
	(5/99 . =3 "Unsure" ), gen(fraud_wrongabsentee)
	label var fraud_wrongabsentee "Absentee Impersonation"
	tab fraud_wrongabsentee

	recode q54e (1/3 5 9 98 . =1 "Frequently") (4=0 "Almost Never"), gen(fraud_wrongabsentee_binary)
	label var fraud_wrongabsentee_binary "Absentee Impersonation"
	tab fraud_wrongabsentee_binary

	*Officials change count 
	tab q54f
	tab q54f, nol
	recode q54f (1=5 "Very Common") (2=4 "Occasional") (3=2 "Infrequent") (4=1 "Never") ///
	(5/99 . =3 "Unsure" ), gen(fraud_officialscheat)
	label var fraud_officialscheat "Officials Change Vote Count"
	tab fraud_officialscheat

	recode q54f (1/3 5 9 98. =1 "Frequently") (4=0 "Almost Never"), gen(fraud_officialscheat_binary)
	label var fraud_officialscheat_binary "Absentee Impersonation"
	tab fraud_officialscheat_binary

	*Unsure of fraud indicator
	gen fraud_unsure = 1 if fraud_voter ==3 | fraud_tamper ==3 | ///
	fraud_impersonation ==3 | fraud_noncitizen ==3 | fraud_wrongabsentee ==3 ///
	| fraud_officialscheat==3 
	replace fraud_unsure  = 0 if fraud_unsure  != 1
	tab fraud_unsure  
	tab   fraud_voter fraud_unsure
	tab   fraud_tamper fraud_unsure
	tab   fraud_impersonation fraud_unsure
	tab   fraud_noncitizen fraud_unsure
	tab   fraud_wrongabsentee fraud_unsure
	tab   fraud_officialscheat fraud_unsure

	gen fraud_scale = fraud_voter + fraud_tamper + fraud_impersonation + ///
	fraud_noncitizen + fraud_wrongabsentee + fraud_officialscheat
	replace fraud_scale = fraud_scale - 6
	replace fraud_scale = fraud_scale/6
	label var fraud_scale  "Fraud Belief Scale"
	tab fraud_scale 

	gen voter_fraud_scale = fraud_voter + fraud_impersonation + ///
	fraud_noncitizen + fraud_wrongabsentee 
	tab voter_fraud_scale 
	replace voter_fraud_scale = voter_fraud_scale - 4
	*replace voter_fraud_scale = voter_fraud_scale/4
	replace voter_fraud_scale = voter_fraud_scale/16
	replace voter_fraud_scale = voter_fraud_scale * 100 
	
	label var voter_fraud_scale  "Voter Fraud Belief Scale"
	tab voter_fraud_scale 

	alpha fraud_tamper fraud_officialscheat
	gen election_fraud_scale =  fraud_tamper + fraud_officialscheat
	tab election_fraud_scale 
	replace election_fraud_scale = election_fraud_scale - 2
	replace election_fraud_scale = election_fraud_scale/2
	label var election_fraud_scale  "Election Fraud Belief Scale"
	tab election_fraud_scale 

*Hacking
tab q55 
tab q56
*Reform proposals
local vars q53a q53b q53c q53d q53e q53f q53g q53h q53i q53j q53k
foreach x of local vars {
recode `x' (1=3 "Strongly Support") (2=2 "Somewhat Support") (3=1 "Somewhat Oppose") ///
(4=0 "Strongly Oppose") (8 9/99=.) , gen(`x'_recode)
}
 
          
label var q53a_recode "Support for Internet Voting"
label var q53b_recode "Support for Cell-Phone Voting"
label var q53c_recode "Support for All-Mail Elections"
label var q53d_recode "Support for Auto-Register at 18"
label var q53e_recode "Support for Election-Day Registration"
label var q53f_recode "Support for Voter ID"
label var q53g_recode "Support for Paper Back-Up at Machines"
label var q53h_recode "Support for Weekend Election-Day"
label var q53i_recode "Support for Election-Day as Holiday"
label var q53j_recode "Support for Non-Partisan Election Official Selection"
label var q53k_recode "Support for Auto-Register After Moving" 

rename  q53a_recode    support_internet_voting
rename  q53b_recode    support_cellphone_voting
rename  q53c_recode   support_allmail
rename  q53d_recode   support_autoreg_18
rename  q53e_recode    support_edr
rename  q53f_recode    support_vid
rename  q53g_recode    support_paperbackup
rename  q53h_recode   support_weekend_ed
rename  q53i_recode    support_holiday_ed
rename  q53j_recode    support_nonpartisan_leo
rename  q53k_recode    support_autoreg_move

local vars q53a q53b q53c q53d q53e q53f q53g q53h q53i q53j q53k
foreach x of local vars {
recode `x' (1/2=1 "Support") (3/4=0 "Oppose") ///
(8 9/99=.) , gen(`x'_recode_b)
}
 
label var q53a_recode_b "Support for Internet Voting"
label var q53b_recode_b "Support for Cell-Phone Voting"
label var q53c_recode_b "Support for All-Mail Elections"
label var q53d_recode_b "Support for Auto-Register at 18"
label var q53e_recode_b "Support for Election-Day Registration"
label var q53f_recode_b "Support for Voter ID"
label var q53g_recode_b "Support for Paper Back-Up at Machines"
label var q53h_recode_b "Support for Weekend Election-Day"
label var q53i_recode_b "Support for Election-Day as Holiday"
label var q53j_recode_b "Support for Non-Partisan Election Official Selection"
label var q53k_recode_b "Support for Auto-Register After Moving" 

rename  q53a_recode_b    support_internet_voting_b
rename  q53b_recode_b    support_cellphone_voting_b
rename  q53c_recode_b   support_allmail_b
rename  q53d_recode_b   support_autoreg_18_b
rename  q53e_recode_b    support_edr_b
rename  q53f_recode_b    support_vid_b
rename  q53g_recode_b    support_paperbackup_b
rename  q53h_recode_b   support_weekend_ed_b
rename  q53i_recode_b    support_holiday_ed_b
rename  q53j_recode_b    support_nonpartisan_leo_b
rename  q53k_recode_b    support_autoreg_move_b

/*Creating variable to include drop offs with in persons		
	*sd_index3
		tab q4
		tab race if q4 == 3 & sd_barrier_pwvoter2 != .

		gen sd_pw_masks3 =1 if sd_pw_masks == 1 | sd_pw_masks2 ==1 
		replace sd_pw_masks3 = 0 if sd_pw_masks == 0  
		replace sd_pw_masks3 = 0 if sd_pw_masks2 ==0
		tab sd_pw_masks3

		gen sd_pw_faceshield3 =1 if sd_pw_faceshield == 1 | sd_pw_faceshield2 ==1 
		replace sd_pw_faceshield3 = 0 if sd_pw_faceshield == 0  
		replace sd_pw_faceshield3 = 0 if sd_pw_faceshield2 ==0
		tab sd_pw_faceshield3

		gen sd_barrier_pwvoter3 =1 if sd_barrier_pwvoter == 1 | sd_barrier_pwvoter2 ==1 
		replace sd_barrier_pwvoter3 = 0 if sd_barrier_pwvoter == 0  
		replace sd_barrier_pwvoter3 = 0 if sd_barrier_pwvoter2 ==0
		tab sd_barrier_pwvoter3

		gen sd_barrier_booths3 =1 if sd_barrier_booths == 1 | sd_barrier_booths2 ==1 
		replace sd_barrier_booths3 = 0 if sd_barrier_booths == 0  
		replace sd_barrier_booths3 = 0 if sd_barrier_booths2 ==0
		tab sd_barrier_booths3

		gen sd_booth_placement3 =1 if sd_booth_placement == 1 | sd_booth_placement2 ==1 
		replace sd_booth_placement3 = 0 if sd_booth_placement == 0  
		replace sd_booth_placement3 = 0 if sd_booth_placement2 ==0
		tab sd_booth_placement3

		gen sd_sixfeet3 =1 if sd_sixfeet == 1 | sd_sixfeet ==1 
		replace sd_sixfeet3 = 0 if sd_sixfeet == 0  
		replace sd_sixfeet3 = 0 if sd_sixfeet ==0
		tab sd_sixfeet3

		gen sd_handsanitizer3 =1 if sd_handsanitizer == 1 | sd_handsanitizer2 ==1 
		replace sd_handsanitizer3 = 0 if sd_handsanitizer == 0  
		replace sd_handsanitizer3 = 0 if sd_handsanitizer2 ==0
		tab sd_handsanitizer

		gen sd_singleusepens3 =1 if sd_singleusepens == 1 | sd_singleusepens ==1 
		replace sd_singleusepens3 = 0 if sd_singleusepens == 0  
		replace sd_singleusepens3 = 0 if sd_singleusepens ==0
		tab sd_singleusepens3

		gen sd_boothscleaned3 =1 if sd_boothscleaned == 1 | sd_boothscleaned2 ==1 
		replace sd_boothscleaned3 = 0 if sd_boothscleaned == 0  
		replace sd_boothscleaned3 = 0 if sd_boothscleaned2 ==0
		tab sd_boothscleaned3

		gen sd_index3 = .
		replace sd_index3 = sd_index3 if sd_index3  !=. & sd_index3 == .
		replace sd_index3 = sd_index3 + sd_index2 
		tab sd_index3
*/
	*Poll worker characteristics







*Age
tab birthyr
gen age = 2020-birthyr
label var age Age

gen age2 = age * age
label var age2 "Age Squared"

*gender
tab gender
recode gender (1=0 "Male") (2=1 "Female"), gen(female)
label var female Female

*race
tab race
recode race (1=1 "White") (2/8=0 "Not White"), gen(white_non_hispanic)
label var white_non_hispanic "White"

recode race (2=1 "Black") (1 3/8=0 "Not Black"), gen(black_non_hispanic)
label var black_non_hispanic "Black"

recode race (3=1 "Hispanic") (1 2 4/8=0 "Not Hispanic"), gen(hispanic)
label var hispanic "Hispanic"

recode race (4/8=1 "Other") (1/3=0 "Not Other"), gen(other_non_hispanic)
label var other_non_hispanic "Other"
	
*Education
tab educ
rename educ educ_precode
recode educ (1/2=1 "HS/Less") (3=2 "Some College") (4=3 "Assoc.") (5=4 "Bach.") ///
(6=5 "Adv."), gen(educ)
label var educ Education

*Marital status
tab marstat
recode marstat (1=1 "Married") (2/6=0 "Not Married"), gen(married)
label var married Married

*Employment
tab employ
recode employ (1/2=1 "Employed") (3/98=0 "Unemployed"), gen(employed)
label var employed Employed

*Income
tab faminc_new
recode faminc_new (12/16=12) (97=.), gen(income_mean)
sum income_mean 
replace income_mean = 6 if income_mean == .
label var income_mean "Income"

*PID
tab pid3 
tab pid3, nol
recode pid3 (1=1 "Democrat") (2=3 "Republican") (3/5=2 "Independent"), gen(pid3_recode)
label var pid3_recode Partisanship
tab pid3_recode

recode pid3 (1=1 "Democrat") (2/5=0 "Not Democrat"), gen(dem)
label var dem Democrat

recode pid3 (2=1 "Republican") (1 3/5=0 "Not Republican"), gen(rep)
label var rep Republican

recode pid3 (3/5=1 "Independent") (1/2=0 "Not Independent"), gen(ind)
label var ind Independent

tab pid7 
tab pid7, nol
recode pid7 (1=1 "Strong Democrat") (2=2 "Moderate Democrat") (3=3 "Lean Democrat") ///
(4 8=4 "Independent") ///
(5=5 "Lean Republican") (6=6 "Moderate Republican") (7=7 "Strong Republican"), gen(pid7_recode)
label var pid7_recode Partisanship
tab pid7_recode

recode pid7 (1=1 "Strong Democrat") (2/8=0 "Not Strong Democrat"), gen(dem_strong) t
label var dem_strong "Strong Democrat"

recode pid7 (2=1 "Moderate Democrat") (1 3/8=0 "Not Moderate Democrat"), gen(dem_mod) t
label var dem_mod "Moderate Democrat"

recode pid7 (3=1 "Lean Democrat") (1 2 4/8=0 "Not Lean Democrat"), gen(dem_lean) t
label var dem_lean "Lean Democrat"

recode pid7 (4 8=1 "Independent") (1/3 5/7=0 "Not Independent"), gen(ind_nolean) t
label var ind_nolean "Independent"

recode pid7 (5=1 "Lean Republican") (1/4 6/7=0 "Not Lean Republican"), gen(rep_lean) t
label var rep_lean "Lean Republican"

recode pid7 (6=1 "Moderate Republican") (1/5 7=0 "Not Moderate Republican"), gen(rep_mod) t
label var rep_mod "Moderate Republican"

recode pid7 (7=1 "Strong Republican") (1/6=0 "Not Strong Republican"), gen(rep_strong) t
label var rep_strong "Strong Republican"

gen rep_w_lean = 1 if pid7_recode >4
replace rep_w_lean = 0 if pid7_recode <5
label var rep_w_lean "Republican"

gen dem_w_lean = 1 if pid7_recode <4
replace dem_w_lean = 0 if pid7_recode >3
label var dem_w_lean "Democrat"

*Voted for winner
gen voted_for_winner = 1 if pid7_recode <4
replace voted_for_winner  = 0 if pid7_recode >3
label var voted_for_winner "Voted for Winner"

*2016 vote
tab presvote16post
recode presvote16post (1/6=1 "Voted") (7=0 "Did not Vote"), gen(voted_2016)
label var voted_2016 "Voted in 2016"

recode presvote16post (3=1 "Voted for Trump") (1/2 4/7=0 "Did not Vote for Trump"), gen(voted_2016_trump)
label var voted_2016_trump "Voted for Trump in 2016"

*Zip code
tab inputzip

*State
tab inputstate
rename inputstate state_fips
label var state_fips "State Fips"
statastates, fips(state_fips)
drop _merge

*Ideology
tab ideo5
recode ideo5 (1=5 "Very Liberal") (2=4 "Liberal") (3=3 "Moderate") ///
(4=2 "Conservative") (5=1 "Very Conservative") (6=3), gen(liberalism)
label var liberalism Liberalism

*Political interest
tab newsint
recode newsint (1=1 "High Interest") (2/98=0 "Low Interest"), gen(poli_int)
label var poli_int "Political Interest"

*Religion
tab religpew 
tab pew_churatd 
tab pew_bornagain 
tab pew_religimp 
tab pew_prayer

*Mailed ballots to voters
gen mail_ballots_to_voters = 1 if state_abbrev == "WA" | state_abbrev == "OR" | ///
state_abbrev == "CA" | state_abbrev == "NV" | state_abbrev == "UT" | state_abbrev == "CO" | ///
state_abbrev == "HI" | state_abbrev == "DC" | state_abbrev == "VT" | state_abbrev == "NJ" 
replace mail_ballots_to_voters = 0 if mail_ballots_to_voters  != 1
 
*Save
save "G:\My Drive\Backup 08202022\Working Papers\Michaels Edited Volume\Election Policies Fraud Beliefs Confidence\Data and Methods\2020 SPAE Cleaned.dta", replace
stop

*Support for ID
tab support_vid_b [aw=weight]
tab support_vid_b if black ==1 [aw=weight]
tab support_vid_b if hispanic ==1 [aw=weight]
tab support_vid_b if white ==1 [aw=weight]
tab support_vid_b if age <30 [aw=weight]
tab support_vid_b if age >30 [aw=weight]
tab support_vid_b if income_mean <5 [aw=weight]
tab support_vid_b if income_mean >4 [aw=weight]
tab support_vid_b if educ ==1 [aw=weight]
tab support_vid_b if educ >1 [aw=weight]
tab support_vid_b if dem_w_lean ==1 [aw=weight]
tab support_vid_b if rep_w_lean ==1 [aw=weight]
tab support_vid_b if ind_nolean ==1 [aw=weight]

ci means support_vid_b [aw=weight]
ci means support_vid_b if black ==1 [aw=weight]
ci means support_vid_b if hispanic ==1 [aw=weight]
ci means support_vid_b if white ==1 [aw=weight]
ci means support_vid_b if age <30 [aw=weight]
ci means support_vid_b if age >30 [aw=weight]
ci means support_vid_b if income_mean <5 [aw=weight]
ci means support_vid_b if income_mean >4 [aw=weight]
ci means support_vid_b if educ ==1 [aw=weight]
ci means support_vid_b if educ >1 [aw=weight]
ci means support_vid_b if dem_w_lean ==1 [aw=weight]
ci means support_vid_b if ind_nolean ==1 [aw=weight]
ci means support_vid_b if rep_w_lean ==1 [aw=weight]

ci means support_vid_b [aw=weight]
ci means support_vid_b if black ==1 [aw=weight]
ci means support_vid_b if hispanic ==1 [aw=weight]
ci means support_vid_b if white ==1 [aw=weight]
ci means support_vid_b if age <30 [aw=weight]
ci means support_vid_b if age >30 [aw=weight]
ci means support_vid_b if income_mean <5 [aw=weight]
ci means support_vid_b if income_mean >4 [aw=weight]
ci means support_vid_b if educ ==1 [aw=weight]
ci means support_vid_b if educ >1 [aw=weight]
ci means support_vid_b if dem_w_lean ==1 [aw=weight]
ci means support_vid_b if ind_nolean ==1 [aw=weight]
ci means support_vid_b if rep_w_lean ==1 [aw=weight]


sum confidence_ownvote confidence_countyvote confidence_statevote confidence_natlvote /// DV
	      /// COVI
	voted_first_time wait_time4 voted_early reg_problem machine_problem difficulty_finding_poll /// Voting Exp.
	hispanic black_non_hispanic other_non_hispanic /// Race/Ethnicity
	age income_mean educ married female /// SES
	dem rep liberalism poli_int /// Poli Characteristics
	state_fips
	
stop
tab sd_index9
drop if voted_inperson == 0
collapse sd_index9 [pw=weight], by(state_fips)
clonevar statefips = state_fips
maptile sd_index9, geoid(statefips) geo(state) ///
twopt(legend(title("Average Covid-19" "Safety Policies (0-9)", size(*.7))) /// 
title("Covid-19 Safety Policy Distribution", color(black)))

sort sd_index9 
bro
